#include "../NewSyndrome-module.h"
#include <errno.h>
#include <time.h>

#ifdef WIN32
#include <winsock.h>

#else
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#include <sys/types.h>
#include <arpa/inet.h>
#include <sys/time.h>
#include <fcntl.h>
typedef struct sockaddr_in SOCKADDR_IN;
#endif


typedef struct _requete requete;
struct _requete
{
  int sock;
  char *buffer;
  unsigned int buffer_len;
  byte avt;
  char *ou;
  char *get;
  unsigned int get_len;
  unsigned int timestart;
  unsigned int divers[5];
  void *p_divers;
  void (*fct_free_divers) (void *pdiv);
  int (*fct_parse_it) (requete * req);
  requete *next;
  requete *prev;
};

typedef struct _requete_conf requete_conf;
struct _requete_conf
{
  byte reperr;
  unsigned int timeout;
  unsigned int nbmax;
  unsigned int nbcur;
};

enum
{ REQFAILURE, REQTIMEOUT };

void add_requete (char *o, char *re, int (*pfct) (requete * req));
requete *rm_requete (requete * head, requete * one);
int connexion_tcp (char *serv, int port);
int data_in_wait (int sock);
int reception_tcp (requete * dc);
byte reqs_are_connected (void);
void requete_error (requete * req, byte coderr);
void requete_init_default (void);
int ready_to_send (int *sock);

extern requete *req_head;
extern requete_conf req_conf;
